package com.gitee.swsk33.catprovider.service.impl;

import com.gitee.swsk33.catprovider.dao.CatDAO;
import com.gitee.swsk33.catprovider.dataobject.Cat;
import com.gitee.swsk33.catprovider.model.Result;
import com.gitee.swsk33.catprovider.service.CatService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@DubboService
@Component
public class CatServiceImpl implements CatService {

	@Autowired
	private CatDAO catDAO;

	@Override
	public Result add(Cat cat) {
		Result result = new Result();
		if (catDAO.add(cat) != 1) {
			result.setResultFailed("添加失败！");
		}
		result.setResultSuccess("添加成功!", null);
		return result;
	}

	@Override
	public Result<Cat> get(int id) {
		Result result = new Result();
		Cat getCat = catDAO.get(id);
		if (getCat == null) {
			result.setResultFailed("获取失败！");
		}
		result.setResultSuccess("获取成功！", getCat);
		return result;
	}

}